package com.mrd.gtimp.business.service;

import com.mrd.base.BaseBiz;
import com.mrd.exception.SaveException;
import com.mrd.gtimp.base.entity.Company;
import com.mrd.gtimp.business.entity.ContacterModel;
import com.mrd.spring.repository.BaseRepository;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Date;

import javax.annotation.Resource;

@Service
public class ContacterModelBiz extends BaseBiz<ContacterModel> {


    @Resource
    // 该处指定注入BaseRepository的dao对象
    @Qualifier("contacterModelDao")
    public void setBaseRepository(BaseRepository<ContacterModel, String> baseRepository) {
        super.baseRepository = baseRepository;
    }

	/*
     * (non-Javadoc)
	 * @see
	 * com.mrd.gtimp.business.biz.ContacterBiz#saveConcater(com.mrd.gtimp.business.pojo.Contacter,
	 * com.mrd.gtimp.base.pojo.Company, java.lang.String)
	 */

    public void saveConcater(ContacterModel contacter, Company customer, String creator)
            throws SaveException {
        if (contacter != null) {
            if (null == contacter.getId() || "".equals(contacter.getId())) {
                contacter.setId(null);
                contacter.setOwner(customer);
                contacter.setCREATOR(creator);
                contacter.setCTIME(new Date());
            }
            baseRepository.saveOrupdate(contacter);
        }
    }

}
